package com.huang.view;

import java.util.ArrayList;
import java.util.List;

import com.huang.R;
import com.huang.view.common.MyListAdapter;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewStub;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ListView;

public class MainActivity extends Activity {

	/* 布局的组件 */
	private ViewStub mVS_main;
	private View mHomeView; /* 主页面，可变部分 */
	private ImageButton mIbtnAllMusic;
	private ImageButton ibtnMusic;
	private ListView musicListView;
	private List<String> musicList;

	/* Ohter */
	private MyListAdapter mListAdapter;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		this.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题栏
		setContentView(R.layout.main_bg);
		/* 代码跟xml的组件绑定 */
		mIbtnAllMusic = (ImageButton) findViewById(R.id.ibtn_all_music);
		ibtnMusic = (ImageButton) findViewById(R.id.ibtn_music);
		musicListView = (ListView) findViewById(R.id.play_list);
		mVS_main = (ViewStub)findViewById(R.id.ivs_fun_btn);
		mHomeView = (View) findViewById(R.id.icd_play_list);
		
		/* 事件绑定 */
		ibtnMusic.setOnClickListener(ibtnOnClickListenter);
		
		/*初始化数据*/
		fillArray();
		musicListView.setAdapter(new MyListAdapter(this, musicList));
		
		/* 显示中间部分页面 */
		mVS_main.inflate();		
		mHomeView.setVisibility(View.INVISIBLE);
	}

	/* 测试数组 */
	private void fillArray() {
		musicList = new ArrayList<String>();
		musicList.add("老黄大人");
		musicList.add("老黄大人");
		musicList.add("老黄大人");
		musicList.add("小凤小人");
		musicList.add("小凤小人");
		musicList.add("老黄大人");
		musicList.add("老黄大人");
		musicList.add("老黄大人");
		musicList.add("小凤小人");
		musicList.add("小凤小人");
	}

	private OnClickListener ibtnOnClickListenter = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			mVS_main.setVisibility(View.INVISIBLE);
			mHomeView.setVisibility(View.VISIBLE);
		}
	};
}